{{define "title"}}{{ .Console.Name }}{{end}}

{{define "favicon"}}
  {{if .Console.FaviconURL}}
    <link rel="icon" type="{{ .Console.FaviconURL | faviconMIMEType }}" href="{{ .Console.FaviconURL }}" />
  {{else}}
    <link id="favicon" rel="shortcut icon" type="image/png" href="/static/common/favicon/milo-32.png">
  {{end}}
{{end}}

{{define "head"}}
  <link rel="stylesheet" href="/static/common/css/console.css" type="text/css">
  <script src="/static/common/third_party/js/js.cookie.js"></script>
  <script>
    var defaultExpand = {{ .Expand }};
  </script>
{{end}}

{{ define "controls" }}
(Show:
<a href="?limit=">default</a>
<a href="?limit=25">25</a>
<a href="?limit=50">50</a>
<a href="?limit=100">100</a>
<a href="?limit=200">200</a>
)
[
  <a href="#" class="control-expand">expand</a>
  <a href="#" class="control-collapse">collapse</a>
]
{{ end }}

{{define "body"}}
{{ $console := .Console }}
<div id="console-page" class="collapsed">

<!-- Title -->
<div class="console-title">
{{ if $console.FaviconURL }}
  <img src="{{ .Console.FaviconURL }}" />
{{ end }}

  <h1>{{ $console.Name }}</h1>
</div>

<!-- Header -->
{{ if $console.Header }}
{{ $header := $console.Header }}

<!-- Tree Status -->
{{ with $header.TreeStatus }}
  <div class="tree-status tree-status-{{ .GeneralState }}">
    <a title="Last updated at {{ .Date }} by {{ .Username }}"
       href="{{ .URL }}"
       aria-label="Tree status: {{ .Message }}.  Last updated at {{ .Date }} by {{ .Username }}">
      {{ .Message }}
    </a>
  </div>
{{ end }}

{{ if or $header.Oncalls $header.Links $header.ConsoleGroups }}
<div class="console-header">
  <div class="console-header-column">

    {{ with $header.Oncalls }}
    <!-- Oncalls -->
    <div class="console-header-group">
      <div class="console-header-group-title">Oncalls</div>
      <div class="console-header-groups">
      {{ range . }}
        <div class="console-header-oncalls-group">
          <div class="console-header-group-name">
            {{ .Name }}
          </div>
          <div class="console-header-group-content">
            {{ .Oncallers }}
          </div>
        </div>
      {{ end }}
      </div>
    </div>
    {{ end }}

    <!-- Links -->
    <div class="console-header-group">
      <div class="console-header-group-title">Links</div>
      <div class="console-header-groups">
      {{ range $header.Links }}
        <div class="console-header-links-group">
          <div class="console-header-group-name">{{ .Name }}</div>
          <div class="console-header-group-content">
          {{ range .Links }}
            <span>{{ .HTML }}</span>
          {{ end }}
          </div>
        </div>
      {{ end }}
      </div>
    </div>
  </div>
{{ if $header.ConsoleGroupsErr }}
  <div class="console-header-column">
    <div style="color: red;" class="console-header-group">
      {{ $header.ConsoleGroupsErr }}
    </div>
  </div>
{{ end }}
{{ if $header.ConsoleGroups }}
  <div class="console-header-column">
  {{ range $header.ConsoleGroups }}

    <!-- Header Group -->
    <!-- If the title is nil, don't wrap it in a special div. -->
    {{ if .Title }}
    <div class="console-header-group">
      <div class="console-header-group-title">
        {{ .Title.HTML }}
      </div>
    {{ end }}
      <div class="console-header-groups">
      {{ range .Consoles }}
        {{ if gt (len .Builders) 30 }}
        <div class="console-builder-summary-flex fill-row">
          <div class="console-header-name">
            {{ .Name.HTML }}
          </div>
          <div class="console-builder-summary-grid">
        {{ else }}
        <div class="console-builder-summary-flex">
          <div class="console-header-name">
            {{ .Name.HTML }}
          </div>
          <div class="console-builder-summary-flex">
        {{ end }}

            {{ $console_name := .Name.Link.Label }}

            {{ range .Builders }}
              <a class="console-builder-status"
                 href="{{ .LastFinishedBuildIDLink }}"
                 title="{{ .BuilderID }}"
                 aria-label="builder {{ .BuilderID }} on console {{ $console_name }} has last status {{ .LastFinishedStatus }}">
                <div class="console-header-builder status-{{ .LastFinishedStatus }}"></div>
              </a>
            {{ end }}
          </div>
        </div>
      {{ end }}
      </div>
    <!-- If the title is nil, don't wrap it in a special div. -->
    {{ if .Title }}
    </div>
    {{ end }}

  {{ end }}
  </div>
{{ end }}
</div>
{{ end }}
{{ end }}

<!-- Legend -->
<div id="legend">
  <table>
    <tr>
      <td>Legend:&nbsp;&nbsp;</td>
      <td class="status-Success" title="All tests passed">Passed</td>
      <td class="status-Failure" title="There is a new failure. Take a look!">Failed</td>
      <td class="status-Running" title="The tests are still running">Running</td>
      <td class="status-Exception" title="Something went wrong with the test, there is no result">Exception</td>
    </tr>
  </table>
</div>
<div class="clear"></div>

<!-- Container -->
<div id="console" class="console-row {{ if not $console.HasCategory }}no-category{{ end }}">
  <!-- Commits -->
  <div class="console-column console-commits-column">
    <div class="console-controls">
      {{ template "controls" }}
    </div>
    <div class="console-row">
      <div class="console-commit-column">
      {{ range $console.Commit }}
        <div class="console-commit-item">
          <!--- This overlay is positioned relative to its parent and used for
                creating the horizontal solid divider line.
                The size and position of the overlay does not affect its siblings.-->
          <div class="console-commit-item-overlay"></div>
          <div class="console-commit-summary">
            <div class="console-commit-revision">
              <a href="{{.Revision.URL}}" aria-label="revision {{ .Revision.Label | prefix 8 }}">
                {{ .CommitTime | localTimeTooltip (.Revision.Label | prefix 8) "N/A" }}
              </a>
            </div>
            <div class="console-commit-author">
              <span title="{{ .Description }}" aria-label="commit by {{ .AuthorEmail }}">
                {{ .AuthorEmail }}
              </span>
            </div>
          </div>
          <div class="console-commit-description">
            <p>
              {{ range .DescLines }}
                {{ . }}<br>
              {{ end }}
            </p>
            <!--- Overlay on top of the commit message for rendering the fadeout -->
            <div class="console-commit-description-overlay"></div>
          </div>
        </div>
      {{ end }}
      </div>
    </div>
  </div>

  <!-- Table -->
  {{ $console.ConsoleTable }}
</div>

<div class="epiloge" style="margin-top: 1em">
  {{ template "controls" }}
</div>

<script src="/static/common/js/console.js"></script>

</div> <!-- console-page -->
{{end}} <!-- Body -->
